﻿var SendAjax = function (metod, data, func) {
    $("#loadingPanel").show();
    $.ajax({
        type: "Get",
        url: "/Medora.Web"+metod,
        contentType: "application/json; charset=utf-8",
        data: data,
        dataType: "json",
        success: function (d) {
            func(d);
            $("#loadingPanel").hide();
        },
        error: function (response) { toastr.error(response.status + " " + response.statusText); }
    });
};

var PostAjax = function (metod, data, func) {
    $("#loadingPanel").show();
    $.ajax({
        type: "Post",
        url: "/Medora.Web" + metod,
        contentType: "application/json; charset=utf-8",
        data: data,
        dataType: "json",
        success: function (d) {
            func(d);
            $("#loadingPanel").hide();
        },
        error: function (response) { toastr.error(response.status + " " + response.statusText); }
    });
};

var DeleteAjax = function (metod, data, func) {
    $("#loadingPanel").show();
    $.ajax({
        type: "Delete",
        url: "/Medora.Web" + metod,
        contentType: "application/json; charset=utf-8",
        data: data,
        dataType: "json",
        success: function (d) {
            var rtn =func(d);
            $("#loadingPanel").hide();
            return rtn;
        },
        error: function (response) { toastr.error(response.status + " " + response.statusText); }
    });
};

isDoubleClick = function (oldValue, currentValue) {
    var responseTime = 400;

    if ((currentValue - oldValue) <= responseTime) {

        self.clickTime = currentValue;
        return true;
    }

    self.clickTime = currentValue;
    return false;
};